package online.heycm.codegenerator.common.jdbc;

import online.heycm.codegenerator.common.types.DBType;

/**
 * 数据库连接填充
 *
 * @author heycm
 * @since 2023/12/17 19:34
 */
public class UrlTemplate {

    private static final String MYSQL_URL = "jdbc:mysql://%s:%s/%s?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&remarks=true&useInformationSchema=true";

    private static final String ORACLE_URL = "jdbc:oracle:thin:@//%s:%s:%s";

    public static String getUrl(DBType dbType, String ip, String port, String schema) {
        if (dbType == DBType.MySQL) {
            return String.format(MYSQL_URL, ip, port, schema);
        }
        if (dbType == DBType.Oracle) {
            return String.format(ORACLE_URL, ip, port, schema);
        }
        return "";
    }
}
